package com.white.note.base;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

public abstract class BaseFragment extends Fragment {
    protected View rootView;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        rootView = inflater.inflate(getLayoutResid(), null);
        return rootView;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initViews();
        setListener();
        initData();
    }


    /**
     * 加载布局文件
     *
     * @return
     */
    protected abstract int getLayoutResid();

    /**
     * 初始化控件
     */
    protected abstract void initViews();

    /**
     * 点击事件
     */
    protected abstract void setListener();

    /**
     * 初始化数据
     */
    protected abstract void initData();
}
